package com.newzqxq.common.constant;

/**
 * @Description ：
 * @Author ： 解风
 * @Date ： 2017/09/13 17:21
 */
public enum CodeEnum {

    FAIL_SYS(-2, "系统异常"),
    FAIL_TOKEN(-1, "登录异常！"),
    SUCCESS(0, "成功！"),
    FAIL(1, "失败！"),
    USER_LOGIN_ERROR_2(2, "账号未注册"),
    USER_LOGIN_ERROR_3(3, "账号或密码错误"),
    USER_LOGIN_ERROR_4(4, "验证码错误"),

    PARAM_LOST(5, "参数缺失"),
    SELECT_ORDER(6, "查询订单信息失败"),
    ORDER_NOT_USER(7, "订单与用户信息不匹配"),
    ORDER__STATUS_ERROR(8, "订单状态有误"),
    ORDER__ERROR(9, "订单异常"),

    FAIL_TOKEN_SIGNATURE(10, "签名异常！"),
    USER_ERROR(11, "用户信息错误"),
    USER_LACK(12, "用户信息不完善"),
    BLACK_USER(13, "请至其他产品"),
    ORDER_EXIST(14, "订单已存在"),
    FAIL_FACE(15, "人脸对比失败"),
    FAIL_NOT_FACE(16, "人脸对比失败,请对准面部拍照"),
    FAIL_CREATE_ORDER(17, "创建订单失败"),
    FACE_BEYOND(18, "face请求异常"),

    NET_BUSYING(19, "网络异常"),

    CANNOT_APPLY(20, "请30天后再次申请"),
    UPLOAD_ERROR(21, "文件上传失败"),
    FAIL_10001(10001, "请求错误"),
    FAIL_10003(10003, "操作异常，请联系管理员！"),
    FAIL_UPDATE_10004(10004, "修改失败！"),


    ;
    private int code;
    private String msg;

    // 从int到enum的转换函数
    public static String valueOf(int value) {
        switch (value) {
            case -2:
                return "FAIL_SYS";
            case -1:
                return "FAIL_TOKEN";
            case 0:
                return "SUCCESS";
            case 1:
                return "FAIL";
            case 2:
                return "USER_LOGIN_ERROR_2";
            case 3:
                return "USER_LOGIN_ERROR_3";
            case 4:
                return "USER_LOGIN_ERROR_4";
            case 5:
                return "PARAM_LOST";
            case 6:
                return "SELECT_ORDER";
            case 7:
                return "ORDER_NOT_USER";
            case 8:
                return "ORDER__STATUS_ERROR";
            case 9:
                return "ORDER__ERROR";
            case 10:
                return "FAIL_TOKEN_SIGNATURE";
            case 11:
                return "USER_ERROR";
            case 12:
                return "USER_LACK";
            case 13:
                return "BLACK_USER";
            case 14:
                return "ORDER_EXIST";
            case 15:
                return "FAIL_FACE";
            case 16:
                return "FAIL_NOT_FACE";
            case 17:
                return "FAIL_CREATE_ORDER";
            case 18:
                return "FACE_BEYOND";
            case 19:
                return "NET_BUSYING";
            case 20:
                return "CANNOT_APPLY";
            case 21:
                return "UPLOAD_ERROR";
            case 10001:
            return "FAIL_10001";
            case 10003:
            return "FAIL_10003";
            case 10004:
            return "FAIL_UPDATE_10004";
            default:
                return "";
        }
    }
    CodeEnum(int code, String msg){
        this.code = code;
        this.msg = msg;
    }
    public static Boolean isSuccess(int code){

        return SUCCESS.getCode()==code;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }
}
